$(function () {
    $("#login_btn").click(function () {
        var username = $("#username").val();
        var password = $("#password").val();
        if (username == null) {
            $("#login_error").text("用户名不能为空");
        } else {
            if(password == null){
                $("#login_error").text("密码不能为空");
            } else {
                let data = {username:username, password:password}
                $.post("/login", data, function (result) {
                    if (result != null){
                        window.location.href = "/loginSuccess";
                    } else {
                        $("#login_error").text("用户名或密码错误");
                    }
                }, "json")
            }
        }
    });
});